package com.ruoyi.mobile.service;

import com.ruoyi.mobile.utils.JwtHelper;

/**
 * 维护用户token
 */
public class UserTokenManager
{
    public static String generateToken(Long userID)
    {
        JwtHelper jwtHelper = new JwtHelper();
        return jwtHelper.createToken(userID);
    }

    public static Long getUserId(String token)
    {
        JwtHelper jwtHelper = new JwtHelper();
        Long userId = jwtHelper.verifyTokenAndGetUserId(token);
        if (userId == null || userId == 0)
        {
            return null;
        }
        return userId;
    }
}
